<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="com.gph.saviorframework.common.model.User" %>
<%@ page import="org.apache.shiro.SecurityUtils" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="com.gph.saviorframework.security.service.MenuService" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<%
	String pid=request.getParameter("pid");
%>
<ul class="nav nav-list" id="steptwo">
	<%
		MenuService menuService = WebApplicationContextUtils.
				getWebApplicationContext(getServletConfig().getServletContext()).getBean(MenuService.class);

		List<Map<String,Object>> menus = menuService.findByParent(pid,
				((User) SecurityUtils.getSubject().getPrincipal()).getUsername());

		for(Map map : menus){
			List<Map<String,Object>> subMenus = menuService.findByParent(map.get("id").toString(),
					((User) SecurityUtils.getSubject().getPrincipal()).getUsername());

	%>
	<%if(subMenus.size()>0){%>
		<li class="">
			<a href="" class="dropdown-toggle">
				<i class="<%=map.get("iconCls")%>"></i>
				<span class="menu-text"><%=map.get("text")%></span>
				<b class="arrow fa fa-angle-down"></b>
			</a>
			<ul class="submenu">
				<%
					for(Map sub : subMenus){
						//三级菜单
						List<Map<String,Object>> thridMenus = menuService.findByParent(sub.get("id").toString(),
								((User) SecurityUtils.getSubject().getPrincipal()).getUsername());
				%>
				<%if(thridMenus.size()>0){%>
				<li class="">
					<a href="" class="dropdown-toggle">
						<i class="<%=sub.get("iconCls")%>"></i>
						<%=sub.get("text")%>
						<b class="arrow fa fa-angle-down"></b>
					</a>
					<ul class="submenu">
						<%for(Map thirdMenu : thridMenus){%>
						<li>
							<a data-url="<%=thirdMenu.get("link")%>?pid=<%=pid%>" href="${ctx}/admin?pid=<%=pid%>#<%=thirdMenu.get("link")%>?pid=<%=pid%>" class="menueachlist">
								<i class=""></i>
								<%=thirdMenu.get("text")%>
							</a>
							<b class="arrow"></b>
						</li>
						<%}%>
					</ul>
				</li>
				<%}else{%>
				<li>
					<a data-url="<%=sub.get("link")%>?pid=<%=pid%>" href="${ctx}/admin?pid=<%=pid%>#<%=sub.get("link")%>?pid=<%=pid%>" class="menueachlist">
						<i class=""></i>
						<%=sub.get("text")%>
					</a>
					<b class="arrow"></b>
				</li>
				<%}%>

				<%}%>
			</ul>
		</li>
	<%}else{%>
			<li>
				<a data-url="<%=map.get("link")%>?pid=<%=pid%>" href="${ctx}/admin?pid=<%=pid%>#<%=map.get("link")%>?pid=<%=pid%>" class="menueachlist">
					<i class=""></i>
					<%=map.get("text")%>
				</a>
				<b class="arrow"></b>
			</li>
		<%}}%>

</ul><!-- /.nav-list -->